home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / software / temacd / godfather / TGF_069.exe / $INSTDIR / Scripts / 04 Advanced ID3 sync.sct < prev    next >
Encoding:
Text File  |  2005-02-06  |  4.9 KB  |  132 lines

  1. { the algorithm is not a complete one and is purpose is to show the possibilities of the gTag variable usage
  2.       property Track1: string read FGetTrack1;
  3.       property Artist1: string read FGetArtist1;
  4.       property Title1: string read FGetTitle1;
  5.       property Album1: string read FGetAlbum1;
  6.       property Genre1: string read FGetGenre1;
  7.       property Year1: string read FGetYear1;
  8.       property Comment1: string read FGetComment1;
  9.       property Track2: string read FGetTrack2;
  10.       property Artist2: string read FGetArtist2;
  11.       property Title2: string read FGetTitle2;
  12.       property Album2: string read FGetAlbum2;
  13.       property Genre2: string read FGetGenre2;
  14.       property Year2: string read FGetYear2;
  15.       property Comment2: string read FGetComment2;
  16.  
  17.       //Tag fields
  18.       property Track: string read FTrack write FTrack;
  19.       property TrackF: string read FFormatTrack;
  20.       property Artist: string read FArtist write FArtist;
  21.       property Title: string read FTitle write FTitle;
  22.       property Album: string read FAlbum write FAlbum;
  23.       property Genre: string read FGenre write FGenre;
  24.       property Year: string read FYear write FYear;
  25.       property Comment: string read FComment write FComment;
  26.       property Language: string read FLanguage write FLanguage;
  27.       property Composer: string read FComposer write FComposer;
  28.       property Copyright: string read FCopyright write FCopyright;
  29.       property URL: string read FURL write FURL;
  30.       property EncodedBy: string read FEncodedBy write FEncodedBy;
  31.       property Lyrics: string read FLyrics write FLyrics;
  32.       property Tones: string read FTones write FTones;
  33.       property Styles: string read FStyles write FStyles;
  34.       property Mood: string read FMood write FMood;
  35.       property Situation: string read FSituation write FSituation;
  36.       property Rating: string read FRating write FRating;
  37.       property Quality: string read FQuality write FQuality;
  38.       property Tempo: string read FTempo write FTempo;
  39.       property Type_: string read FType write FType;
  40.       //
  41.  
  42.       // audio info
  43.       property Bitrate: string read FBitrate;
  44.       property Mode: string read FMode;
  45.       property SampleRate: string read FSampleRate;
  46.       property EncoderUsed: string read FEncoderUsed;
  47.       property Version: string read FVersion;
  48.       property VBR: boolean read FVBR;
  49.       // Other
  50.       property PicCount: integer read FPicCount;
  51.       property HasPictures: boolean read FHasPictures;
  52.       property HasLyrics: boolean read FHasLyrics;
  53.       property TagExists: boolean read FTagExists;
  54.  
  55.       property FileType: integer read FFileType;
  56.       property TagType: integer read FTagType;
  57.       property FileSize: integer read FFileSize;
  58.       property AudioSize: integer read FAudioSize;
  59.       property Duration: integer read FDuration;
  60.       property DurationF: string read FFormatDuration;
  61.  
  62.       property Caption: string read FCaption;
  63.       property CaptionTag1: string read FCaptionTag1;
  64.       property CaptionTag2: string read FCaptionTag2;
  65.       property ResultStr : string read FResultStr;
  66. }
  67.  
  68. // this program will not use the values from the grid
  69. // it will rather reload the actual tags from each file ( slower )
  70. Program ID3_sync;
  71.  
  72. const
  73.   _BAD_TITLE = 'TRACK*';
  74.   _BAD_ARTIST = 'UNKNOWN*';
  75.  
  76. var
  77.   sTmp1, sTmp2: string;
  78.   bUpdated: boolean;
  79.  
  80.   // we will use the advanced delphi MatchesMask function for this
  81.   procedure Fix_field( const sField,sValue: string );
  82.   begin
  83.     if MatchesMask( tg_getField( sField ), sValue ) then begin //probaply bogus field in the grid
  84.        bUpdated := true;
  85.        if MatchesMask( sTmp1, sValue ) then begin // was ID3v1 responsible ?
  86.  
  87.           if MatchesMask( sTmp2, sValue ) then begin // was ID3v2 same crap ?
  88.              tg_setField( sField, '' ) // better have nothing
  89.           end else begin
  90.              tg_setField( sField, sTmp2 ) // force id3v2 title field
  91.           end;
  92.  
  93.        end else if MatchesMask( sTmp2, sValue ) then begin // was ID3v2 responsible ?
  94.  
  95.           if MatchesMask( sTmp1, sValue ) then begin // was ID3v1 same crap ?
  96.              tg_setField( sField, '' ) // better have nothing
  97.           end else begin
  98.              tg_setField( sField, sTmp1 ) // force id3v1 title field
  99.           end;
  100.  
  101.        end;
  102.  
  103.     end;
  104.  
  105.   end;
  106.  
  107.  
  108. begin
  109.  
  110.   tg_Init;
  111.  
  112.   repeat
  113.  
  114.     tg_LoadFile; // re load info from file so we can use the gTag class variable
  115.     if gTag.TagType <> 1 then continue; // not and ID3 tag file
  116.     bUpdated := false;
  117.     // do something for the title field
  118.     sTmp1 := gTag.Title1; // id3v1 field
  119.     sTmp2 := gTag.Title2; // id3v2 field
  120.     Fix_field( 'Title', _BAD_TITLE );
  121.  
  122.     // do something for the artist field
  123.     sTmp1 := gTag.Artist1; // id3v1 field
  124.     sTmp2 := gTag.Artist2; // id3v2 field
  125.     Fix_field( 'Artist', _BAD_ARTIST );
  126.  
  127.     if bUpdated then tg_setresult( '!' );
  128.  
  129.   until not tg_Skip;
  130.  
  131. end.
  132.